/* eslint-disable */
// @ts-ignore
import { queryOptions, useMutation } from '@tanstack/vue-query';
import type { DefaultError } from '@tanstack/vue-query';
import request from '@/utils/request';
import { CustomRequestOptions } from '@/interceptors/request';

import * as apis from './weixinyonghukongzhiqi';
import * as API from './types';

/** 绑定分销商户账户 POST /tourism/client/c/user/bindFzUser */
export function useBindFzUserUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultBoolean_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.bindFzUserUsingPost,
    onSuccess(data: API.CommonResultBoolean_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 生成小程序码 POST /tourism/client/c/user/generateWxaQrCode */
export function useGenerateWxaQrCodeUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultString_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.generateWxaQrCodeUsingPost,
    onSuccess(data: API.CommonResultString_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 获取用户信息 GET /tourism/client/c/user/getUserInfo */
export function getUserInfoUsingGetQueryOptions(options: {
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.getUserInfoUsingGet(queryKey[1] as typeof options);
    },
    queryKey: ['getUserInfoUsingGet', options],
  });
}

/** 登录 POST /tourism/client/c/user/login */
export function useLoginUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultString_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.loginUsingPost,
    onSuccess(data: API.CommonResultString_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 退出 POST /tourism/client/c/user/logout */
export function useLogoutUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultString_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.logoutUsingPost,
    onSuccess(data: API.CommonResultString_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 注册 POST /tourism/client/c/user/register */
export function useAddUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultString_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.addUsingPost,
    onSuccess(data: API.CommonResultString_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 修改用户信息 POST /tourism/client/c/user/updateUserInfo */
export function useUpdateUserInfoUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultString_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.updateUserInfoUsingPost,
    onSuccess(data: API.CommonResultString_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 上传头像 POST /tourism/client/c/user/uploadAvatar */
export function useUploadDynamicReturnUrlUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultString_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.uploadDynamicReturnUrlUsingPost,
    onSuccess(data: API.CommonResultString_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 微信小程序登录 POST /tourism/client/c/user/wxMaLogin */
export function useWxMaLoginUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultString_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.wxMaLoginUsingPost,
    onSuccess(data: API.CommonResultString_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}
